import request from './request'

// 获取用户数据列表
export const getUsers = (params) => {
  return request({
    url: '/users',
    method: 'GET',
    params
  })
}

// 修改用户状态
export const setState = (id, type) => {
  return request({
    url: `users/${id}/state/${type}`,
    method: 'put',
  })
}

// 添加用户
export const addUserData = (data) => {
  return request({
    url: '/users',
    method: 'POST',
    data
  })
}

// 编辑用户提交
export const editUser = (data) => {
  return request({
    url: `users/${data.id}`,
    method: 'put',
    data
  })
}

// 删除用户
export const delUser  =(data) => {
  return request({
    url: `users/${data.id}`,
    method: 'delete',
    data
  })
}

// 分配用户角色
export const allocation = (select,rid) => {
  return request({
    url: `users/${select.id}/role`,
    method: 'put',
    data: rid
  })
}

// 获取角色列表
export const getrolesList = () => {
  return request({
    url: 'roles'
  })
}
